package com.example.process.node;

import com.example.process.node.enums.ProcessTemplateEnum;
import com.example.process.util.SpringUtil;
import org.springframework.stereotype.Component;
/***
 * @description: 审核入口
 * @author ts2333
 * @date: 2022/6/15 15:34
 */
@Component
public class ProcessClient {

    public boolean execute(NodeContext context) {
        Integer templateCode = context.getTemplateCode();
        Integer nodeCode = context.getNodeCode();
        boolean pass = context.isPass();
        Class<? extends BaseTemplate> serviceClass = ProcessTemplateEnum.getTemplateClassByTemplateType(templateCode);
        NodeProcessor nodeProcessor = SpringUtil.getBean(serviceClass).getNodeMap().get(nodeCode);
        return pass ? nodeProcessor.pass(context) : nodeProcessor.reject(context);
    }

}
